//
//  HYOUSetUpViewController.m
//  BestGift
//
//  Created by 温晓宇 on 16/1/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HYOUSetUpViewController.h"
#import "HYOUSetUpView.h"
#import "HYOUHeadView.h"
#import "UMSocial.h"
#import "HYOUMyViewController.h"
@interface HYOUSetUpViewController ()<HYOUHeadViewDelegate,HYOUSetUpView>

@property(nonatomic, retain)HYOUSetUpView *setup;

@end

@implementation HYOUSetUpViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"night"];
    if ([str isEqualToString:@"yes"]) {
        self.setup.nightWitch.on = YES;
    } else {
        self.setup.nightWitch.on = NO;
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    HYOUHeadView *head = [[HYOUHeadView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 64)];
    [self.view addSubview:head];
    head.delegate = self;
    
    
    self.setup = [[HYOUSetUpView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT - 44)];
    self.setup.delegate = self;
    [self.view addSubview:self.setup];
}
-(void)popView{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
-(void)clear{
    NSInteger size = [[SDImageCache sharedImageCache]getSize];
    float sizeMB = size/1024.0/1024.0;
    NSLog(@"清除前%.2fMB",sizeMB);
    
    UIAlertController *alart = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"确定清除%.1fMB缓存", sizeMB] preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        [[SDImageCache sharedImageCache] clearDisk];
        // [[NSUserDefaults standardUserDefaults]setObject:[NSString stringWithFormat:@"%.2fMB",sizeMB] forKey:@"caches"];
        NSLog(@"清除后%.2fMB",sizeMB);
        //            [self.myTableView reloadData];
        
    }];
    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alart addAction:sure];
    [alart addAction:cancel];
    [self presentViewController:alart animated:YES completion:^{
        
    }];
}
-(void)showMyView{
    HYOUMyViewController *my = [[HYOUMyViewController alloc] init];
    [self.navigationController pushViewController:my animated:YES];
}
#pragma mark -- 审核 分享
-(void)UMSocial{
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"568dcee0e0f55afe6f001e85"
                                      shareText:@"App:BestGift"
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:nil
                                       delegate:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
